< previous page page_672 next page >

Page 672
Microsoft Jet enables you to nest transactions up to five levels deep. If you are using external ODBC databases, however, you cannot nest transactions.
Summary
Today, you learned about the three important challenges that face every database programmer writing multiuser applications:
· Using database locking schemes
· Using cascading updates and deletes to maintain database integrity
· Using database transactions to provide commit/rollback options for major updates to your database
You learned that three levels of locking are available to Visual Basic programs:
· Database level: You can use the Exclusive property of the data control or the second parameter of the OpenDatabase method to lock the entire database. Use this option when you need to perform work that affects multiple database objects (such as tables, queries, indexes, relations, and so on).
· Table level: You can set the Options property of the data control to 3 or the third parameter of the OpenRecordset method to dbDenyRead+dbDenyWrite in order to lock the entire table for your use only. Use this option when you need to perform work that affects multiple records in a single table (for example, increasing the sales price on all items in the inventory table).
· Page level: Microsoft Jet automatically performs page-level locking whenever you use the data control to edit and save a record, or whenever you use Visual Basic code to perform the Edit/AddNew and Update/CancelUpdate methods. You can use the LockEdits property of the Recordset to set the page locking to pessimistic (to perform locking at edit time) or optimistic (to perform locking only at update time).
You learned how to use Visual Basic to enforce referential integrity and automatically perform cascading updates or deletes to related records. You learned that there are times when it is not advisable to establish cascading deletes (for example, do not use cascading deletes when the base table is a validation list and the foreign table is a master).
Finally, you learned how to use database transactions to protect your database during extended, multitable operations. You learned how to use the BeginTrans, CommitTrans, and Rollback methods of the workspace object. Finally, you learned some of the advantages and limitations of transaction processing.

 
< previous page page_672 next page >

If you like this book, buy it!